Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[debug dump util] Base Skeleton and Click Class added #1668

Merged
merged 29 commits into from
Sep 7, 2021

Conversation

vivekrnv
Copy link
Contributor

Signed-off-by: Vivek Reddy Karri [email protected]

DEBUG DUMP UTIL PR SEQ: 3

NOTE: PLEASE MERGE #1667 BEFORE MERGING THIS

What I did

HLD for Dump Utility: HLD.

  • Added the top level CLI command i.e "dump state"
  • Added corresponding UT's
  • Added the bash autocompletion support files
  • Added the implementation for the customization options provided, such as --db, --key-map, --show, --table & --namespace

How I did it

How to verify it

UT's are implemented

tests/dump_tests/dump_state_test.py::TestDumpState::test_identifier_single PASSED [ 81%]
tests/dump_tests/dump_state_test.py::TestDumpState::test_identifier_multiple PASSED [ 81%]
tests/dump_tests/dump_state_test.py::TestDumpState::test_option_key_map PASSED [ 82%]
tests/dump_tests/dump_state_test.py::TestDumpState::test_option_db_filtering PASSED [ 82%]
tests/dump_tests/dump_state_test.py::TestDumpState::test_option_tabular_display PASSED [ 82%]
tests/dump_tests/dump_state_test.py::TestDumpState::test_option_tabular_display_no_db_filter PASSED [ 82%]
tests/dump_tests/dump_state_test.py::TestDumpState::test_identifier_all_with_filtering PASSED [ 82%]
tests/dump_tests/dump_state_test.py::TestDumpState::test_namespace_single_asic PASSED [ 82%]
tests/dump_tests/dump_state_test.py::TestDumpStateMultiAsic::test_default_namespace PASSED [ 82%]
tests/dump_tests/dump_state_test.py::TestDumpStateMultiAsic::test_namespace_asic0 PASSED [ 82%]
tests/dump_tests/dump_state_test.py::TestDumpStateMultiAsic::test_namespace_asic1 PASSED [ 82%]
tests/dump_tests/dump_state_test.py::TestDumpStateMultiAsic::test_invalid_namespace PASSED [ 82%]
admin@sonic:~$ dump state --help
Usage: dump state [OPTIONS] MODULE IDENTIFIER

  Dump the redis-state of the identifier for the module specified

Options:
  -s, --show            Display Modules Available
  -d, --db TEXT         Only dump from these Databases
  -t, --table           Print in tabular format  [default: False]
  -k, --key-map         Only fetch the keys matched, don't extract field-value
                        dumps  [default: False]
  -v, --verbose         Prints any intermediate output to stdout useful for
                        dev & troubleshooting  [default: False]
  -n, --namespace TEXT  Dump the redis-state for this namespace.  [default: ]
  --help                Show this message and exit.


admin@sonic:~$ dump state --show
Module    Identifier
--------  ------------
copp      trap_id
port      port_name

admin@sonic:~$ dump state port Ethernet0 --table --db ASIC_DB --key-map
+-------------+-----------+-----------------------------------------------------------+
| port_name   | DB_NAME   | DUMP                                                      |
+=============+===========+===========================================================+
| Ethernet0   | ASIC_DB   | +-------------------------------------------------------+ |
|             |           | | Keys Collected                                        | |
|             |           | +=======================================================+ |
|             |           | | ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF:oid:0xd000000000a21 | |
|             |           | +-------------------------------------------------------+ |
|             |           | | ASIC_STATE:SAI_OBJECT_TYPE_PORT:oid:0x10000000008d4   | |
|             |           | +-------------------------------------------------------+ |
|             |           | +---------------------+---------------------+             |
|             |           | | vid                 | rid                 |             |
|             |           | +=====================+=====================+             |
|             |           | | oid:0xd000000000a21 | oid:0xd             |             |
|             |           | +---------------------+---------------------+             |
|             |           | | oid:0x10000000008d4 | oid:0x1690000000001 |             |
|             |           | +---------------------+---------------------+             |
+-------------+-----------+-----------------------------------------------------------+

admin@sonic:~$ dump state port Ethernet0 --db ASIC_DB --key-map
{
    "Ethernet0": {
        "ASIC_DB": {
            "keys": [
                "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF:oid:0xd000000000a21",
                "ASIC_STATE:SAI_OBJECT_TYPE_PORT:oid:0x10000000008d4"
            ],
            "tables_not_found": [],
            "vidtorid": {
                "oid:0xd000000000a21": "oid:0xd",
                "oid:0x10000000008d4": "oid:0x1690000000001"
            }
        }
    }
}

Additional Output samples can be found in the HLD Link

vivekrnv added 22 commits May 14, 2021 05:12
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
@lgtm-com
Copy link

lgtm-com bot commented Jun 24, 2021

This pull request introduces 1 alert when merging 164a2ee into 5708497 - view on LGTM.com

new alerts:

  • 1 for Unused import

@vivekrnv
Copy link
Contributor Author

Request for 202106

Copy link
Contributor

@arlakshm arlakshm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments

dump/main.py Outdated Show resolved Hide resolved
dump/main.py Outdated Show resolved Hide resolved
dump/main.py Show resolved Hide resolved
dump/main.py Outdated Show resolved Hide resolved
dump/main.py Show resolved Hide resolved
dump/main.py Outdated Show resolved Hide resolved
dump/main.py Show resolved Hide resolved
dump/main.py Outdated Show resolved Hide resolved
dump/main.py Outdated Show resolved Hide resolved
Signed-off-by: Vivek Reddy Karri <[email protected]>
Signed-off-by: Vivek Reddy Karri <[email protected]>
arlakshm
arlakshm previously approved these changes Aug 17, 2021
Copy link
Contributor

@arlakshm arlakshm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

Signed-off-by: Vivek Reddy Karri <[email protected]>
@lgtm-com
Copy link

lgtm-com bot commented Aug 19, 2021

This pull request introduces 2 alerts when merging 4266484 into 29f4a16 - view on LGTM.com

new alerts:

  • 1 for Unused import
  • 1 for Wrong number of arguments in a class instantiation

Copy link
Contributor

@SuvarnaMeenakshi SuvarnaMeenakshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@vivekrnv
Copy link
Contributor Author

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vivekrnv
Copy link
Contributor Author

Hi @arlakshm, Can you review the changes and signoff?

@dgsudharsan
Copy link
Collaborator

@arlakshm Can you please review and sign off?

@SuvarnaMeenakshi SuvarnaMeenakshi merged commit 9f2326e into sonic-net:master Sep 7, 2021
SuvarnaMeenakshi pushed a commit that referenced this pull request Nov 10, 2021
What I did
Implemented vlan and vlan_member modules for debug dump utility.

How I did it
Used infrastructure and followed examples in
#1666
#1667
#1668
#1669
#1670

How to verify it
On switch: dump state vlan <vlan_name>
dump state vlan_member '<vlan_name|<member_name>'
Unit test: pytest-3 dump_tests/module_tests/vlan_test.py (same test file covers both vlan and vlan_member)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants